import 'package:safetymonitor/app/components/custom_refresh.dart';
import 'package:safetymonitor/app/core/core.dart';
import 'package:safetymonitor/app/core/http/http.dart';
import 'package:safetymonitor/app/core/utils/interface.dart';
import 'package:safetymonitor/app/data/entities/application/preventive_rectification_entity.dart';
import 'package:safetymonitor/router/app_pages.dart';

///已完成
class CompletedController extends GetxController {
  /// 列表刷新key
  final GlobalKey<CustomEasyRefreshListState> globalKey = GlobalKey();
  String searchX = '';

  /// 获取数据
  Future<List<PreventiveRectificationEntity>> getCompanyDeviceListEntity(
      int index, int size,
      {String? search}) async {
    final res = await HttpUtil()
        .generateGetRequest<List<PreventiveRectificationEntity>>(
      Interface.preventiveRectification,
      queryParameters: {
        'pageNo': index,
        'pageSize': size,
        'status': 7,
        'preventiveName': searchX,
      },
    ).execute();
    List<PreventiveRectificationEntity>? list = [];
    res.onSuccess((result) {
      if (result.data != null) {
        list = result.data;
        //删除7（已完成）
      }
    });
    return list ?? [];
  }

  void refreshPage() {
    globalKey.currentState?.onRefresh();
  }

  void onClickDetail(PreventiveRectificationEntity item) {
    Get.toNamed(Routes.completedStatePage,arguments: item.id);
  }
}
